package com.ojoin.trade.t0loan_core.web.dao;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.data.domain.Pageable;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.web.dao.BaseDao;
import com.ojoin.trade.t0loan_core.web.domain.T0LoanLiveUserHistoryTransTotalInfoVO;
import com.ojoin.trade.t0loan_core.web.domain.TbT0LoanLiveApplication;
import com.ojoin.trade.t0loan_core.web.domain.TbT0LoanLiveInfoVO;
import com.ojoin.trade.t0loan_core.web.domain.TbT0LoanTodoTaskVO;

public interface TbT0LoanLiveApplicationDao extends BaseDao<TbT0LoanLiveApplication> {

	public SqlSession getSqlSession();
	
	public List<TbT0LoanLiveApplication> queryT0LoanLiveInfoByJoinUserID(
			int joinuserid) throws BusinessException;

	public List<TbT0LoanLiveApplication> queryT1LoanLiveInfoByJoinUserID(
			int joinuserid) throws BusinessException;
	
	public List<TbT0LoanLiveInfoVO> queryAllT0LoanLiveInfoByStatus(
			Integer loanstatus, Pageable page) throws BusinessException;
	
	public List<TbT0LoanLiveInfoVO> queryAllTxLoanLiveInfoByApplying(
			Pageable page, String operatetype) throws BusinessException;
	
	public int updateT0LoanLiveInfoByLiveIDsAndStatus(int[] liveids, 
			int loanstatus) throws BusinessException;
	
	public int updateTxLoanLiveInfoByLiveIDsAndStatus(String operatetype, int[] liveids, int idOfTbMerchantUserOfCreditor, 
			int loanstatus) throws BusinessException;
	
	public TbT0LoanLiveApplication queryNewlyT0LoanLiveInfoByJoinUserID(
			int joinuserid) throws BusinessException;
	
	public TbT0LoanLiveApplication queryNewlyTxLoanLiveInfoByJoinUserID(
			int joinuserid, String operatetype) throws BusinessException;
	
	public List<T0LoanLiveUserHistoryTransTotalInfoVO> queryT0LoanLiveUserHistoryTransTotalInfoList(Pageable page) 
			throws BusinessException;
	
	/**
	 * 审核用户Tx业务申请不通过，提交不通过原因并更新状态为-1
	 * @return
	 * @throws BusinessException
	 */
	public int updateTxLoanLiveInfoApplyNoPassByLiveID(String operatetype, int liveid,
			String memo) throws BusinessException;
			
	/**
	 * 修改T+0贷款申请记录的设定手续费和利率，并更新状态为2 (T0000034)
	 * @param liveid
	 * 
	 * 说明：修改tb_t0_loan_live_application表中liveid为传入参数值的记录的
	 * 申请状态status为2，fee/ratio为传入参数，记录业务日志
	 * 
	 * @throws BusinessException
	 */
	public int updateT0LoanLiveInfoFeeAndRatioByLiveID(int liveid, String fee, 
			String ratio, String expected_loan_time, int creditorid) throws BusinessException;
	
	/**
	 * 修改T+0贷款申请记录的授信额度、生成相关文件，并更新状态为3 (T0000035)
	 * 
	 * 说明：
	 * 1)、调用金融账户开户(JA000012)
	 * 2)、生成保理合同pdf文件，填充相关内容
	 * 3)、生成账户变更申请表文件，填充相关内容
	 * 4)、更新授信额度及保理合同、账户变更申请表文件路径及状态为3
	 * 
	 * @param liveid
	 * @param joinuserid
	 * @param rm_daily_threshold
	 * @param rm_single_threshold
	 * @param qryprintscreen
	 * @param contractfilepath
	 * @param accchangeapplyfilepath
	 * @throws BusinessException
	 */
	public int updateT0LoanLiveInfoLimitByLiveID(int liveid, int joinuserid, 
			String rm_daily_threshold, String rm_single_threshold, String qryprintscreen, 
			String contractfilepath, String accchangeapplyfilepath) throws BusinessException;

	/**
	 * 查询指定九盈用户申请T+0贷款记录状态为3的信息，获取生成的保理合同和账户变更申请表(T0000036)
	 * @param joinuserid
	 * 
	 * @return
	 * String[0] 保理合同
	 * String[1] 账户变更申请表
	 * 
	 * @throws BusinessException
	 */
	public String[] queryT0LoanLiveContractFileByJoinuserid(int joinuserid) throws BusinessException;
	
	/**
	 * 上传用户盖章后的账户变更申请表，修改T+0贷款申请记录的状态为4 (T0000037)
	 * @param liveid
	 * @param joinuserid
	 * @param changefilepath
	 * @throws BusinessException
	 */
	public int uploadT0LoanUserCommitFileByLiveID(int liveid, String userchangefilepath) throws BusinessException;

	/**
	 * 用户提交的账户变更申请表审核通过，修改T+0贷款申请记录的状态为5
	 * @param liveid
	 * @return
	 * @throws BusinessException
	 */
	public int updateT0LoanLiveInfoUserCommitPass(int liveid) throws BusinessException;
	
	/**
	 * 审核用户提交的账户变更申请表不通过，提交不通过原因并更新状态为6
	 * @param liveid
	 * @return
	 * @throws BusinessException
	 */
	public int updateT0LoanLiveInfoUserCommitNoPassByLiveID(int liveid, String memo) throws BusinessException;
	
	/**
	 * 上传核查的商户账户余额查询截图，修改T+0贷款申请记录的状态为7
	 * @param liveid
	 * @param materials
	 * @throws BusinessException
	 */
	public int uploadT0LoanAccountChangeFileByLiveID(int liveid, String materials) throws BusinessException;

	/**
	 * 查询后台管理员代办任务列表
	 * @return
	 * @throws BusinessException
	 */
	public List<TbT0LoanTodoTaskVO> queryAdminUserTodoTaskList() throws BusinessException;
	
	/**
	 * 查询保理员代办任务列表
	 * @return
	 * @throws BusinessException
	 */
	public List<TbT0LoanTodoTaskVO> queryOperatorTodoTaskList() throws BusinessException;
	
}
